home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
021-030
/
amok21
/
iffsupport1.5
/
demos
/
saveiff.mod
< prev
next >
Wrap
Text File
|
1993-11-04
|
13KB
|
426 lines
(*---------------------------------------------------------------------------
:Program. SaveIFF.mod
:Author. Fridtjof Siebert
:Address. Nobileweg 67, D-7-Stgt-40
:Phone. 0711/822509
:Shortcut. [fbs]
:Version. 1.0
:Date. 26-Jun-88
:Copyright. PD
:Language. Modula-II
:Translator. M2Amiga
:Imports. none.
:UpDate. none.
:Contents. Speichert Screens und Windows als IFF-Files.
:Remark. Demonstartion für IFFSupport.
---------------------------------------------------------------------------*)
MODULE SaveIFF;
FROM SYSTEM IMPORT ADR, ADDRESS, BITSET, LONGSET, SHIFT, CAST;
FROM Arts IMPORT TermProcedure, Assert;
FROM Dos IMPORT Delay;
FROM Exec IMPORT Forbid, GetMsg, Permit, ReplyMsg, WaitPort;
FROM Graphics IMPORT Text, Move, Draw, SetAPen, SetDrMd, jam1, jam2,
RastPortPtr, SetBPen, Rectangle, RectFill;
FROM Intuition IMPORT IntuitionBase, NewWindow, OpenWindow, CloseWindow,
WindowFlags, WindowFlagSet, Gadget, GadgetFlags,
GadgetFlagSet, WindowPtr, ActivationFlags,
ActivationFlagSet, ScreenFlags, ScreenFlagSet,
IDCMPFlags, IDCMPFlagSet, RefreshGadgets, strGadget,
StringInfo, IntuiMessagePtr, GadgetPtr, ScreenPtr,
boolGadget, CloseScreen, DisplayBeep;
FROM Strings IMPORT Length, Copy, first, last;
FROM IFFSupport IMPORT ReadILBM, ReadILBMFlags, ReadILBMFlagSet, WriteILBM;
IMPORT Intuition;
TYPE
Gadgets = (scrn0,scrn1,scrn2,scrn3,scrn4,scrn5,scrn6,scrn7,scrn8,scrn9,
wind0,wind1,wind2,wind3,wind4,wind5,wind6,wind7,wind8,wind9,
name, savescrn, savewind, savegzz, showiff, dummy);
VAR
Intuitionbase: POINTER TO IntuitionBase; (* IntuitionBasePtr *)
NuWindow: NewWindow;
Window: WindowPtr; (* SaveIFF's Window *)
RP: RastPortPtr; (* It's RastPort *)
Gadgs: ARRAY Gadgets OF Gadget; (* It's Gadgets *)
NameInfo: StringInfo; (* IFF-Name's Gadget's Info *)
Name: ARRAY[0..79] OF CHAR; (* IFF-Name *)
IDCount: Gadgets; (* Counting Gadgets *)
ChosenScreen, ChosenWindow: Gadgets; (* User-Selected Screnn&Window*)
Screen: ScreenPtr; (* Screen for Loaded IFF-File *)
DummyWind: WindowPtr; (* only a Dummy *)
Screens: ARRAY[scrn0..scrn9] OF ScreenPtr; (* ScreenPtrs *)
Windows: ARRAY[wind0..wind9] OF WindowPtr; (* WindowPtrs *)
NumScreens, NumWindows: Gadgets; (* How many are in that List? *)
gadget: GadgetPtr; (* Gadget causing a Message *)
Msg: IntuiMessagePtr; (* Receives Messages *)
Rect: Rectangle; (* Rectangle for Windows *)
Ciapra [0BFE001H]: SET OF (s0,s1,s2,s3,s4,s5,lmb);
(*----------------------- Small Procedures: -----------------------------*)
(*------ Set a Bool-Gadget: ------*)
PROCEDURE SetBool(VAR Gadg: Gadget; x,y,w,h: INTEGER);
BEGIN
WITH Gadg DO
nextGadget := NIL;
leftEdge := x; topEdge := y;
width := w; height := h;
flags := GadgetFlagSet{};
activation := ActivationFlagSet{gadgImmediate,toggleSelect};
gadgetType := boolGadget;
gadgetRender := NIL;
selectRender := NIL;
gadgetText := NIL;
mutualExclude:= LONGSET{};
specialInfo := NIL;
gadgetID := 0;
userData := NIL;
END;
END SetBool;
(*------ Draw A Box: ------*)
PROCEDURE Box(rp: RastPortPtr; x,y,X,Y: INTEGER);
BEGIN
Move(rp,x,y); Draw(rp,X,y); Draw(rp,X,Y); Draw(rp,x,Y); Draw(rp,x,y);
END Box;
(*------ Type Text: ------*)
TYPE
TypeTextType = POINTER TO ARRAY[0..999] OF CHAR;
PROCEDURE Type(rp: RastPortPtr; x,y: INTEGER; text:TypeTextType);
BEGIN
Move(rp,x,y); Text(rp,text,Length(text^));
END Type;
(*-------------------------------------------------------------------------*)
(* *)
(* Refresh Display: (Gadgets & Names) *)
(* *)
(*-------------------------------------------------------------------------*)
PROCEDURE Refresh(Display: BOOLEAN);
(* IF NOT(Display) THEN Don't make anything affecting the display *)
VAR
SearchScreen: ScreenPtr;
SearchWindow: WindowPtr;
SearchName: ARRAY[0..79] OF CHAR;
NamePtr: POINTER TO ARRAY[0..255] OF CHAR;
BEGIN
(*------ Delete highlighted Gadgets: ------*)
IF Display THEN RefreshGadgets(ADR(Gadgs),Window,NIL) END;
(*------ Get ScreenNames: ------*)
IF Display THEN
SetAPen(RP,0); SetDrMd(RP,jam1); RectFill(RP,9,27,143,109);
SetAPen(RP,1); SetBPen(RP,0); SetDrMd(RP,jam2);
END;
IDCount := scrn0;
Forbid();
SearchScreen := Intuitionbase^.firstScreen;
WHILE (SearchScreen#NIL) AND (IDCount<=scrn9) DO
Screens[IDCount] := SearchScreen;
IF SearchScreen^.title=NIL THEN
SearchName := "Unnamed";
ELSE
NamePtr := SearchScreen^.title;
Copy(SearchName,NamePtr^,first,16);
END;
IF Display THEN Type(RP, 12,35+8*ORD(IDCount),ADR(SearchName)) END;
INC(IDCount);
SearchScreen := SearchScreen^.nextScreen;
END;
Permit();
NumScreens := IDCount;
IF ChosenScreen>=NumScreens THEN ChosenScreen := scrn0 END;
(*------ Get WindowNames: ------*)
IF Display THEN
SetAPen(RP,0); SetDrMd(RP,jam1); RectFill(RP,153,27,287,109);
SetAPen(RP,1); SetBPen(RP,0); SetDrMd(RP,jam2);
END;
IDCount := wind0;
Forbid();
SearchWindow := Screens[ChosenScreen]^.firstWindow;
WHILE (SearchWindow#NIL) AND (IDCount<=wind9) DO
Windows[IDCount] := SearchWindow;
IF SearchWindow^.title=NIL THEN
SearchName := "Unnamed";
ELSE
NamePtr := SearchWindow^.title;
Copy(SearchName,NamePtr^,first,16);
END;
IF Display THEN Type(RP,156,8*ORD(IDCount)-45,ADR(SearchName)) END;
INC(IDCount);
SearchWindow := SearchWindow^.nextWindow;
END;
Permit();
NumWindows := IDCount;
IF ChosenWindow>=NumWindows THEN
IF NumWindows=wind0 THEN
ChosenWindow := dummy;
ELSE
ChosenWindow := wind0;
END;
END;
(*------ Set Gadgets: ------*)
IF Display THEN
FOR IDCount := scrn0 TO showiff DO
WITH Gadgs[IDCount] DO
flags := flags - GadgetFlagSet{selected};
END;
END;
INCL(Gadgs[ChosenScreen].flags,selected);
INCL(Gadgs[ChosenWindow].flags,selected);
END;
(*------ Refresh: ------*)
IF Display THEN RefreshGadgets(ADR(Gadgs),Window,NIL) END;
END Refresh;
(*-------------------------- Clean Up: ----------------------------------*)
PROCEDURE CleanUp();
BEGIN
IF Window#NIL THEN CloseWindow(Window) END;
IF Screen#NIL THEN CloseScreen(Screen) END;
END CleanUp;
(*-------------------------------------------------------------------------*)
(* *)
(* M A I N : *)
(* *)
(*-------------------------------------------------------------------------*)
BEGIN
(*------ Init Variables: ------*)
Window := NIL;
Intuitionbase := NIL;
Screen := NIL;
TermProcedure(CleanUp);
Name := "df0:Pic.iff";
ChosenScreen := scrn0;
ChosenWindow := wind0;
(*------ Open Intuition: ------*)
Intuitionbase := ADR(Intuition);
Assert(Intuitionbase#NIL,ADR("SaveIFF: Can't open Intuition"));
(*------------------------ Build up Display: ----------------------------*)
(*------ Gadgets: ------*)
FOR IDCount:=scrn0 TO scrn9 DO
SetBool(Gadgs[IDCount],9,29+8*ORD(IDCount),135,8);
SetBool(Gadgs[Gadgets(ORD(IDCount)+ORD(wind0))],153,29+8*ORD(IDCount),
135,8);
END;
SetBool(Gadgs[name ], 60,116,224, 8);
WITH Gadgs[name] DO
activation := ActivationFlagSet{stringCenter};
gadgetType := strGadget;
specialInfo := ADR(NameInfo);
END;
WITH NameInfo DO
buffer := ADR(Name);
undoBuffer := NIL;
bufferPos := 0;
maxChars := 80;
dispPos := 0;
numChars := Length(Name);
END;
SetBool(Gadgs[savescrn], 9,131,135,11);
SetBool(Gadgs[savewind],153,131,135,11);
SetBool(Gadgs[savegzz ], 9,147,135,11);
SetBool(Gadgs[showiff ],153,147,135,11);
(*------ Link Gadgets: ------*)
FOR IDCount := scrn0 TO savegzz DO
WITH Gadgs[IDCount] DO
nextGadget := ADR(Gadgs[Gadgets(ORD(IDCount)+1)]);
gadgetID := ORD(IDCount);
END;
END;
WITH Gadgs[showiff] DO
nextGadget := NIL;
gadgetID := ORD(showiff)
END;
(*------ Window: ------*)
WITH NuWindow DO
leftEdge := 172; topEdge := 36;
width := 296; height := 164;
detailPen := 0; blockPen := 1;
idcmpFlags := IDCMPFlagSet{gadgetDown,closeWindow};
flags := WindowFlagSet{windowDrag,windowDepth,windowClose,activate,
noCareRefresh};
firstGadget:= ADR(Gadgs);
checkMark := NIL;
title := ADR("SaveIFF - © F. Siebert");
screen := NIL;
bitMap := NIL;
type := ScreenFlagSet{wbenchScreen};
END;
Window := OpenWindow(NuWindow);
Assert(Window#NIL,ADR("SaveIFF: Can't open Window"));
RP := Window^.rPort;
(*------ Draw into Window: ------*)
SetAPen(RP,2); SetDrMd(RP,jam1);
Box(RP, 8, 26,144,110); Box(RP,152, 26,288,110);
Box(RP, 56,114,288,126); Box(RP, 8,130,144,142);
Box(RP,152,130,288,142); Box(RP, 8,146,144,158);
Box(RP,152,146,288,158);
(*------ Type Text into Window: ------*)
SetAPen(RP,1);
Type(RP, 8, 23,ADR("Screens:"));
Type(RP,152, 23,ADR("Windows:"));
Type(RP, 8,123,ADR("Name:"));
Type(RP, 36,139,ADR("Save Screen"));
Type(RP,180,139,ADR("Save Window"));
Type(RP, 28,155,ADR("Save GimmeZZ"));
Type(RP,188,155,ADR("Show IFF"));
(*------ Initialize Display: ------*)
Refresh(TRUE);
(*---------------------------- Get Messages: ----------------------------*)
LOOP
WaitPort(Window^.userPort);
Msg := GetMsg(Window^.userPort);
IF closeWindow IN Msg^.class THEN
ReplyMsg(Msg);
EXIT;
END;
gadget := Msg^.iAddress;
ReplyMsg(Msg);
IDCount := Gadgets(gadget^.gadgetID);
CASE IDCount OF
(*------ Screen-Gadget: ------*)
scrn0..scrn9:
IF IDCount<NumScreens THEN
ChosenScreen := IDCount;
ELSE
DisplayBeep(NIL);
END; |
(*------ Window-Gadget: ------*)
wind0..wind9:
IF IDCount<NumWindows THEN
ChosenWindow := IDCount;
ELSE
DisplayBeep(NIL);
END; |
(*------ SaveScrn: ------*)
savescrn:
Refresh(FALSE);
WITH Screens[ChosenScreen]^ DO
IF NOT(WriteILBM(Name,ADR(rastPort),ADR(viewPort),NIL,TRUE)) THEN
DisplayBeep(NIL);
END;
END; |
(*------ savewind: ------*)
savewind:
Refresh(FALSE);
IF ChosenWindow#dummy THEN
WITH Windows[ChosenWindow]^ DO
WITH Rect DO
minX := leftEdge;
minY := topEdge;
maxX := minX + width - 1;
maxY := minY + height - 1;
END;
IF NOT(WriteILBM(Name,rPort,ADR(wScreen^.viewPort),ADR(Rect),
TRUE)) THEN
DisplayBeep(NIL);
END;
END;
ELSE
DisplayBeep(NIL);
END; |
(*------ Save GimmeZeroZero: ------*)
savegzz:
Refresh(FALSE);
IF ChosenWindow#dummy THEN
WITH Windows[ChosenWindow]^ DO
WITH Rect DO
minX := leftEdge + ORD(borderLeft);
minY := topEdge + ORD(borderTop);
maxX := minX + gzzWidth - 1;
maxY := minY + gzzHeight - 1;
END;
IF NOT(WriteILBM(Name,rPort,ADR(wScreen^.viewPort),ADR(Rect),
TRUE)) THEN
DisplayBeep(NIL);
END;
END;
ELSE
DisplayBeep(NIL);
END; |
(*------ ShowIFF: ------*)
showiff:
IF ReadILBM(Name,ReadILBMFlagSet{front,visible},Screen,DummyWind) THEN
WHILE lmb IN Ciapra DO Delay(5) END; (* Wait for Left Button *)
CloseScreen(Screen);
Screen := NIL;
ELSE
DisplayBeep(NIL);
END; |
ELSE
END;
Refresh(TRUE);
END; (* LOOP *)
END SaveIFF.